﻿using System.Collections.Generic;
using System.Linq;
using HorseRaceTracker.Domain.Core;

namespace HorseRaceTracker.Application.DTO
{
    public class ResponseGetAllHorses
    {
        private List<HorseInfo> _list;
        public IEnumerable<HorseInfo> Horses { get { return _list; } set { _list = value.ToList(); } }

        public ResponseGetAllHorses()
        {
            _list = new List<HorseInfo>();
        }


    }
    internal class ResponseGetAllHorsesAssembler
    {
        private readonly ResponseGetAllHorses _responseGetAllHorses;
        public ResponseGetAllHorses ResponseGetAllHorses { get
            { _responseGetAllHorses.Horses = _list;
                return _responseGetAllHorses; }
        }
        private readonly List<HorseInfo> _list;
        public ResponseGetAllHorsesAssembler()
        {
            _responseGetAllHorses = new ResponseGetAllHorses();
            _list = new List<HorseInfo>();
        }
        public ResponseGetAllHorsesAssembler AddHorses(IEnumerable<Horse> horses)
        {
            var horseInfoAssember = new HorseInfoAssember();
            foreach (var horse in horses)
            {
                _list.Add(horseInfoAssember.AddHorse(horse).HorseInfo);
            }
            return this;
        }
        public ResponseGetAllHorsesAssembler AddHorse(Horse horse)
        {
            _list.Add(new HorseInfoAssember().AddHorse(horse).HorseInfo);
            return this;
        }
    }

}